﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace CSharpHomework6_2
{
    public partial class Form2 : Form
    {
        public  AllOrder a;
        public Form2()
        {
            InitializeComponent();
            
           
            


        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void label6_Click(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void label7_Click(object sender, EventArgs e)
        {

        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            
            //List<OrderItem> itemlist = new List<OrderItem>();
            List<OrderItem> list = new List<OrderItem>();


            BindingSource bindingSource = new BindingSource();
            bindingSource.DataSource = list;
            itemdata.DataSource = bindingSource;
            foreach (DataGridViewRow rows in itemdata.Rows)
            {
                if(rows.Cells[0]==null)
                {
                    OrderItem orderItem = new OrderItem(rows.Cells[0].Value.ToString(),
                    int.Parse(rows.Cells[1].Value.ToString()),
                    double.Parse(rows.Cells[2].Value.ToString()));

                    list.Add(orderItem);
                }
                
            }

            a.addOrder(int.Parse(orderNum.Text), user.Text, date.Text, list);
            itemdata.Rows.Clear();






            
            
        }

        private void returnbtn_Click(object sender, EventArgs e)
        {
            
            this.Close();
            Form1.a = this.a;
        }
    }
}
